#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>


class Solution {
public:
    bool PredictTheWinner(vector<int>& nums) {
        int s1 = fc(nums,0,nums.size()-1);
        int s2 = lc(nums,0,nums.size()-1);
        return s1 >= s2;
    }
    //先手
    int fc(const vector<int>& nums,int L,int R) {
        if(L == R) {
            return nums[L];
        }
        int socre1 = nums[L] + lc(nums,L+1,R);
        int score2 = nums[R] + lc(nums,L,R-1);
        return max(socre1,score2);
    }
    //后手
    int lc(const vector<int>& nums,int L,int R) {
        //后手纸牌已经被先手拿走了
        if(L == R) {
            return 0;
        }
        //后手被先手决定 对方会把情况最差的留给我 因为二者之和一定
        int socre1 = fc(nums,L+1,R);
        int score2 = fc(nums,L,R-1);
        return min(socre1,score2);
    }
};

int main() {

}